/******************************************************************************
* File:             lamp.c
*
* Author:           iysheng@163.com  
* Created:          03/27/22 
*                   灯具控制函数集合
*****************************************************************************/

#include "sys.h"

#define CAN_DEVICE_ID      0x01

void control_lamp_with_mode(u16 mode)
{
    u8 tx_can_data[8] = {0x7E, 0x01, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7E};
    tx_can_data[4] = mode;
    can_write(CAN_DEVICE_ID, tx_can_data, 8);
    sys_write_vp_u16(TOUCH_EVENT_MODE_ICONS_ADDR, mode);
}

void control_whole_lamp_with_level(u16 level)
{
    u8 tx_can_data[8] = {0x7E, 0x02, 0xff, 0xff, 0x00, 0x00, 0x00, 0x7E};
    tx_can_data[4] = level & 0xff;
    can_write(CAN_DEVICE_ID, tx_can_data, 8);
}

void control_one_lamp_with_level(u16 addr, u16 level)
{
    u8 tx_can_data[8] = {0x7E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E};
    tx_can_data[2] = addr >> 8;
    tx_can_data[3] = addr;
    tx_can_data[4] = level & 0xff;
    can_write(CAN_DEVICE_ID, tx_can_data, 8);
}

